﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WMS.Infrasturcture.Interfaces
{
    /// <summary>
    /// 仓储接口
    /// </summary>
    /// <typeparam name="T">泛型</typeparam>
    public interface IBaseRepository<T>
    {
        /// <summary>
        /// 上下文
        /// </summary>

        DBcontext DB { get; }
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>返回受影响行数</returns>
        Task<int> AddAsync(T entity);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>返回受影响行数</returns>
        Task<int> UpdateAsync(T entity);
        /// <summary>
        /// 查询
        /// </summary>
        /// <returns>返回集合</returns>
        IQueryable<T> GetAll();
        /// <summary>
        /// 删除      
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>返回受影响行数</returns>
        Task<int> Delete(T entity);
        /// <summary>
        /// 批量删除
        /// </summary>
        Task<int> DeleteRange(List<T> entity);
        /// <summary>
        /// 批量新增
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> AddRange(List<T> entity);
    }
}
